<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
	<meta charset="UTF-8">
    <title>账户流水</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <!-- load css -->
    <link rel="stylesheet" th:href="@{/css/font.css}" />
	<link rel="stylesheet" th:href="@{/css/xadmin.css}" />
    <script type="text/javascript" th:src="@{/js/jquery.min.js}"></script>
    <script th:src="@{/js/layui/layui.js}" charset="utf-8"></script>
    <script type="text/javascript" th:src="@{/js/xadmin.js}"></script>
</head>
<body class="layui-anim layui-anim-fadein">
    <div class="x-nav">
      <span class="layui-breadcrumb">
        <a>流水记录</a>
        <a><cite>账户流水</cite></a>
      </span>
      <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
    </div>
    <div class="x-body">
      <div class="layui-row">
        <div class="layui-form layui-col-md12 x-so">
          <input id="user_id" type="text" name="user_id"   placeholder="用户编号" autocomplete="off" class="layui-input" />
         <div class="layui-input-inline">
            <select id="type" name="type">
              <option value="">类型</option>
              <option value="1">商户</option>
              <option value="2">合作商</option>
            </select>
          </div>
          <input id="remarks" type="text" name="remarks"   placeholder="备注" autocomplete="off" class="layui-input" />
			<input type="text" name="timeStr" id="timeStr" readonly="readonly"
		    placeholder="日期" class="layui-input inputHeight"
			style="margin-top: 2px;margin-left: 10px;"> 
          <button id="searchBtn" data-type="reload" class="layui-btn"  lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
        </div>
      </div>
      <table class="layui-hide" id="table1" lay-filter="tool1"></table>
      </div>
<script type="text/html" id="amountTpl">
{{#   if(d.amount < 0){ 
return '<span style="color:red;">'+d.amount+'</span>';
  }else{  
return '<span style="color: green;">+'+d.amount+'</span>';
 }  }}
</script>
<script type="text/html" id="typeTpl">
{{#   if(d.type == 2){ 
return '<span style="color:blue;">合作商</span>';
  }else{  
return '<span style="color: green;">商户</span>';
 }  }}
</script>
<script>
      layui.use(['laydate', 'laypage', 'table'], function(){
        var laydate = layui.laydate,
        table = layui.table, //表格
        laypage = layui.laypage; //分页
        //执行一个 table 实例
        table.render({
          elem: '#table1'
          ,height: 650
          ,limit: 14
          ,limits:[14,20,30,40,50,60,70,80,90]
          ,url: '[[@{/admin/balance/list.html}]]' //数据接口
          ,id:'table1'
          ,page: true
          ,cols: [
           [
        	{field: 'user_id', title: '用户编号', width: '16%', align:'center'}
        	,{field: 'type', title: '用户类型', width: '16%', align:'center',templet:'#typeTpl'}
            ,{field: 'amount', title: '变更金额', width: '16%', align:'center',templet:'#amountTpl'}
            ,{field: 'after_balance', title: '当前余额', width: '16%', align:'center'}
            ,{field: 'remarks', title: '备注', width: '16%', align:'center'}
            ,{field: 'create_time', title: '时间', width: '20%', align:'center'}
             ]
          ]
        });
        $('#searchBtn').on('click', function(){
        	var index = layer.msg('查询中，请稍候...',{icon: 16,time:false,shade:0});
        	table.reload('table1', {
    	        page: {
    	          curr: 1 //重新从第 1 页开始
    	        }
    	        ,where: {
    	            'timeStr': $('#timeStr').val(),
    	            'user_id': $('#user_id').val(),
    	            'type': $('#type').val(),
    	            'remarks': $('#remarks').val(),
    	        }
    	      });
        	layer.close(index);
       });
        
        var timeStr = laydate.render({//渲染结束时间选择  
        	elem : '#timeStr',//通过id绑定html中插入的end  
        	done : function(value, dates) {
        	}
        });
        
      //监听工具条
        table.on('tool(tool1)', function(obj){ //注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
          var data = obj.data //获得当前行数据
          ,layEvent = obj.event; //获得 lay-event 对应的值
        });
      });
    </script>
  </body>
</html>
